
; (function () {
    return
    /**
   * @param {number[]} nums
   * @param {number} k
   * @return {void} Do not return anything, modify nums in-place instead.
   */
    var rotate = function (nums, k) {
        k = k % nums.length

        let arr = nums.slice(nums.length - k, nums.length)
        nums.splice(nums.length - k, k)
        nums.unshift(...arr)

    };

    let arr = [1, 2]
    console.log(rotate(arr, 5));
    console.log(arr);
})();
; (function () {
    //return
    var rotate = function (nums, k) {
        const m = nums.length
        let i = 0
        if (m - k > 0) {
            i = m - k
        } else {
            i = m - k % m
        }
        nums.splice(0, 0, ...nums.splice(i))


    };
    let arr = [1, 2, 3, 4, 5, 6]
    console.log(rotate(arr, 2));
    console.log(arr);
})();

; (function () {
    //return
    var rotate = function (nums, k) {
        const n = nums.length;
        const newArr = new Array(n);
        for (let i = 0; i < n; ++i) {
            newArr[(i + k) % n] = nums[i];
        }
        for (let i = 0; i < n; ++i) {
            nums[i] = newArr[i];
        }
    };

})();